﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Layout.Master" AutoEventWireup="true" CodeBehind="wfDeviceTracking.aspx.cs" Inherits="Dragon.wfDeviceTracking1" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="ManageBAForm" style="width: 100%; height: 100%">        
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>                
            <table class="auto-style1" cellspacing="10px">                  
                <tr>
                    <td class="auto-style5" style="width: 4%; color: #000080;padding-left:5px;">
                        Tỉnh thành 
                    </td>
                    <td class="auto-style6" style="width: 8%;">
                        <asp:DropDownList ID="ddlProvince" runat="server" DataSourceID="sdsProvince" DataTextField="Name" DataValueField="Code" Width="90%" 
                            OnDataBound="ddlProvince_DataBound" ForeColor="#000099" AutoPostBack="True">
                        </asp:DropDownList>                            
                    </td>

                    <td class="auto-style5" style="width: 4%; color: #000080;padding-left:5px;">
                        Nhân viên 
                    </td>
                    <td class="auto-style6" style="width: 8%;">
                        <asp:DropDownList ID="ddlUser" runat="server" DataSourceID="sdsUser" DataTextField="Fullname" DataValueField="Code" Width="90%" 
                            OnDataBound="ddlUser_DataBound" ForeColor="#000099" AutoPostBack="True">
                        </asp:DropDownList>                            
                    </td>

                    <td class="auto-style5"style="width: 4%; color: #000080;padding-left:5px;">
                        Loại dữ liệu
                    </td>
                    <td class="auto-style6"style="width: 8%;">
                        <asp:DropDownList ID="ddlNote" runat="server" DataTextField="Name" DataValueField="Code" Width="90%" ForeColor="#000099" AutoPostBack="True">
                            <asp:ListItem>Time Set</asp:ListItem>
                            <asp:ListItem>Synced</asp:ListItem>
                        </asp:DropDownList>                         
                    </td>

                   <td class="auto-style5"style="width: 4%; color: #000080;padding-left:5px;">
                        Hiển thị
                    </td>
                    <td class="auto-style6"style="width: 8%;">
                        <asp:DropDownList ID="ddlReportType" runat="server" DataTextField="Name" DataValueField="Code" Width="90%" ForeColor="#000099" AutoPostBack="True">
                            <asp:ListItem>Dữ liệu</asp:ListItem>
                            <asp:ListItem>Đồng bộ cuối</asp:ListItem>
                            <asp:ListItem>Đồng bộ thiếu</asp:ListItem>
                            <asp:ListItem>Không hợp lý</asp:ListItem>
                        </asp:DropDownList>                         
                    </td>                   
                </tr>
                           
                <tr>   
                    <td class="auto-style5" style="width: 4%; color: #000080;padding-left:5px;">
                        Từ ngày 
                    </td>
                    <td class="auto-style6" style="width: 8%;">                                          
                        <asp:TextBox ID="txtFromDate" runat="server" Width="90%" ForeColor="#000099" AutoPostBack="True"></asp:TextBox>
                        <cc1:CalendarExtender ID="txtFromDate_CalendarExtender" runat="server" BehaviorID="txtFromDate_CalendarExtender" TargetControlID="txtFromDate" Format="MM/dd/yyyy" />                                          
                    </td>

                    <td class="auto-style5" style="width: 4%; color: #000080;padding-left:5px;">
                        Đến ngày 
                    </td>
                    <td class="auto-style6" style="width: 8%;">                                          
                        <asp:TextBox ID="txtToDate" runat="server" Width="90%" ForeColor="#000099" AutoPostBack="True"></asp:TextBox>
                        <cc1:CalendarExtender ID="txtToDate_CalendarExtender" runat="server" BehaviorID="txtToDate_CalendarExtender" TargetControlID="txtToDate" Format="MM/dd/yyyy" />                                          
                    </td>
                                                   
                    <td class="auto-style2"style="text-align: center;" colspan="4">
                        <asp:Label ID="lblInfo" runat="server" ForeColor="#000099" style="font-weight: 700" Width="100%"></asp:Label>
                    </td>                    
                </tr>
            
                <tr>   
                    <td class="auto-style2" colspan="8" style="height: 100%; vertical-align:top">                                
                        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="sdsDeviceTracking" AllowSorting="True" Width="100%"
                            PageSize="20" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" ShowHeaderWhenEmpty="True"  AllowPaging="True" 
                            OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
                            <Columns>
                                <asp:CommandField SelectText=">>>" ShowSelectButton="True" />
                                <asp:TemplateField SortExpression="Name" ItemStyle-Width="9%">                                                
			                        <HeaderTemplate>
				                        <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Name" Font-Bold="True" ForeColor="White">
                                        Tỉnh thành</asp:LinkButton>
				                        <br />
				                        <asp:TextBox ID="txtName" AutoPostBack="true" runat="server" Width="90%" OnTextChanged="txtFilter_TextChanged"></asp:TextBox>
			                        </HeaderTemplate>
			                        <ItemTemplate>
				                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
			                        </ItemTemplate>		                            
		                        </asp:TemplateField>                                

                                <asp:TemplateField SortExpression="Fullname" ItemStyle-Width="17%">                                                
			                        <HeaderTemplate>
				                        <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Fullname" Font-Bold="True" ForeColor="White">
                                        Họ tên</asp:LinkButton>
				                        <br />
				                        <asp:TextBox ID="txtFullname" AutoPostBack="true" runat="server" Width="90%" OnTextChanged="txtFilter_TextChanged"></asp:TextBox>
			                        </HeaderTemplate>
			                        <ItemTemplate>
				                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("Fullname") %>'></asp:Label>
			                        </ItemTemplate>			                            		                            
		                        </asp:TemplateField>

                                <asp:TemplateField SortExpression="Imei" ItemStyle-Width="11%">                                                
			                        <HeaderTemplate>
				                        <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Imei" Font-Bold="True" ForeColor="White">
                                        Số IMEI</asp:LinkButton>
				                        <br />
				                        <asp:TextBox ID="txtImei" AutoPostBack="true" runat="server" Width="90%" OnTextChanged="txtFilter_TextChanged"></asp:TextBox>
			                        </HeaderTemplate>
			                        <ItemTemplate>
				                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("Imei") %>'></asp:Label>
			                        </ItemTemplate>			                            		                            
		                        </asp:TemplateField>

                                    <asp:TemplateField SortExpression="LocalTime" ItemStyle-Width="16%">                                                
			                        <HeaderTemplate>
				                        <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="LocalTime" Font-Bold="True" ForeColor="White">
                                        Giờ trên máy</asp:LinkButton>
				                        <br />
				                        <asp:TextBox ID="txtLocalTime" AutoPostBack="true" runat="server" Width="90%" OnTextChanged="txtFilter_TextChanged"></asp:TextBox>
			                        </HeaderTemplate>
			                        <ItemTemplate>
				                        <asp:Label ID="Label5" runat="server" Text='<%# Bind("LocalTime", "{0:yy/MM/dd HH:mm:ss}") %>'></asp:Label>
			                        </ItemTemplate>			                            		                                
		                        </asp:TemplateField>

                                    <asp:TemplateField SortExpression="NetworkTime" ItemStyle-Width="16%">                                                
			                        <HeaderTemplate>
				                        <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="NetworkTime" Font-Bold="True" ForeColor="White">
                                        Giờ quốc tế</asp:LinkButton>
				                        <br />
				                        <asp:TextBox ID="txtNetworkTime" AutoPostBack="true" runat="server" Width="90%" OnTextChanged="txtFilter_TextChanged"></asp:TextBox>
			                        </HeaderTemplate>
			                        <ItemTemplate>
				                        <asp:Label ID="Label6" runat="server" Text='<%# Bind("NetworkTime", "{0:yy/MM/dd HH:mm:ss}")%>'></asp:Label>
			                        </ItemTemplate>			                            		                                
		                        </asp:TemplateField>

                                <asp:TemplateField SortExpression="Note" ItemStyle-Width="7%">                                                
			                        <HeaderTemplate>
				                        <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Note" Font-Bold="True" ForeColor="White">
                                        Nội dung</asp:LinkButton>
				                        <br />
				                        <asp:TextBox ID="txtNote" AutoPostBack="true" runat="server" Width="90%" OnTextChanged="txtFilter_TextChanged"></asp:TextBox>
			                        </HeaderTemplate>
			                        <ItemTemplate>
				                        <asp:Label ID="Label7" runat="server" Text='<%# Bind("Note") %>'></asp:Label>
			                        </ItemTemplate>			                            		                            
		                        </asp:TemplateField>

                                <asp:TemplateField SortExpression="Location" ItemStyle-Width="12%">                                                
			                        <HeaderTemplate>
				                        <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Location" Font-Bold="True" ForeColor="White">
                                        Vị trí</asp:LinkButton>
				                        <br />
				                        <asp:TextBox ID="txtLocation" AutoPostBack="true" runat="server" Width="90%" ReadOnly="true"></asp:TextBox>
			                        </HeaderTemplate>
			                        <ItemTemplate>
				                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("Location") %>'></asp:Label>
			                        </ItemTemplate>			                            		                            
		                        </asp:TemplateField>

                                <asp:TemplateField SortExpression="UploadTime" ItemStyle-Width="12%">                                                
			                        <HeaderTemplate>
				                        <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="UploadTime" Font-Bold="True" ForeColor="White">
                                        Giờ đồng bộ</asp:LinkButton>
				                        <br />
				                        <asp:TextBox ID="txtUploadTime" AutoPostBack="true" runat="server" Width="90%" OnTextChanged="txtFilter_TextChanged"></asp:TextBox>
			                        </HeaderTemplate>
			                        <ItemTemplate>
				                        <asp:Label ID="Label8" runat="server" Text='<%# Bind("UploadTime", "{0:yy/MM/dd HH:mm:ss}") %>'></asp:Label>
			                        </ItemTemplate>			                            		                            
		                        </asp:TemplateField>

                                <asp:TemplateField SortExpression="ID" ItemStyle-Width="0px" Visible="false">                                                			                        
			                        <ItemTemplate>
				                        <asp:Label ID="Label9" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
			                        </ItemTemplate>			                            		                            
		                        </asp:TemplateField>

                                <asp:TemplateField SortExpression="Lat" ItemStyle-Width="0px" Visible="false">                                                			                        
			                        <ItemTemplate>
				                        <asp:Label ID="Label10" runat="server" Text='<%# Bind("Lat") %>'></asp:Label>
			                        </ItemTemplate>			                            		                            
		                        </asp:TemplateField>

                                <asp:TemplateField SortExpression="Lng" ItemStyle-Width="0px" Visible="false">
			                        <ItemTemplate>
				                        <asp:Label ID="Label11" runat="server" Text='<%# Bind("Lng") %>'></asp:Label>
			                        </ItemTemplate>			                            		                            
		                        </asp:TemplateField>                                                             
                            </Columns>
                            <EmptyDataTemplate>
		                        Không có dữ liệu. Vui lòng chọn tiêu chí khác!
	                        </EmptyDataTemplate>
	                        <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
	                        <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="#CCCCFF" />
	                        <PagerSettings PageButtonCount="20" Mode="NumericFirstLast" FirstPageText="Trang đầu" LastPageText="Trang cuối" NextPageText="" PreviousPageText="" />
	                        <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" Width="50%" />                                   
	                        <RowStyle BackColor="White" ForeColor="#003399" />	                            
	                        <SortedAscendingCellStyle BackColor="#EDF6F6" />
	                        <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
	                        <SortedDescendingCellStyle BackColor="#D6DFDF" />
	                        <SortedDescendingHeaderStyle BackColor="#002876" />     
                        </asp:GridView>                            
                    </td>                   
                </tr>
            </table>                                 
        </ContentTemplate>
        </asp:UpdatePanel>
    </div>  
    <asp:SqlDataSource ID="sdsProvince" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
        SelectCommand="SELECT [Code], [Name] FROM [Province] WHERE ([Status] = @Status)">
        <SelectParameters>
            <asp:Parameter DefaultValue="1" Name="Status" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
      
    <asp:SqlDataSource ID="sdsUser" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
        SelectCommand="SELECT [User].Code, [User].Fullname FROM Province INNER JOIN Region ON Province.Code = Region.Province 
        INNER JOIN [User] ON Region.Code = [User].Region WHERE (Province.Code = @Province) ORDER BY [User].Fullname">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlProvince" Name="Province" PropertyName="SelectedValue" />
        </SelectParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="sdsDeviceTracking" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
        SelectCommand="sp_Display_Device_Tracking" SelectCommandType="StoredProcedure" OnSelected="sdsDeviceTracking_Selected">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlProvince" Name="ProvinceCode" PropertyName="SelectedValue" Type="String" DefaultValue="0" />
            <asp:ControlParameter ControlID="ddlUser" Name="UserCode" PropertyName="SelectedValue" Type="String" DefaultValue="0" />
            <asp:ControlParameter ControlID="ddlNote" Name="Note" PropertyName="Text" Type="String" DefaultValue="Time Set" />
            <asp:ControlParameter ControlID="txtFromDate" DefaultValue="" Name="FromDate" PropertyName="Text" Type="DateTime" />
            <asp:ControlParameter ControlID="txtToDate" Name="ToDate" PropertyName="Text" Type="DateTime" />
            <asp:Parameter DefaultValue="|" Name="txtName" Type="String" />
            <asp:Parameter DefaultValue="|" Name="txtFullname" Type="String" />
            <asp:Parameter DefaultValue="|" Name="txtImei" Type="String" />
            <asp:Parameter DefaultValue="|" Name="txtLocalTime" Type="String" />
            <asp:Parameter DefaultValue="|" Name="txtNetworkTime" Type="String" />
            <asp:Parameter DefaultValue="|" Name="txtNote" Type="String" />
            <asp:Parameter DefaultValue="|" Name="txtUploadTime" Type="String" />
            <asp:ControlParameter ControlID="ddlReportType" DefaultValue="0" Name="ReportType" PropertyName="SelectedIndex" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>

